package com.le.tester.controller;

import com.le.tester.common.ServerResponse;
import com.le.tester.sevice.StockService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 描述：库存控制层
 */
@Controller
@RequestMapping("/stock/")
public class StockController {
    private static final Logger LOG = LoggerFactory.getLogger(StockController.class);

    @Autowired
    private StockService stockService;

    @ResponseBody
    @RequestMapping(value = "reduce")
    public ServerResponse<String> stockReduce(@RequestParam("goodsId") Long goodsId,
                                              @RequestParam("count") Integer count) {
        String result = stockService.reduceStockRedissonLock(goodsId, count);
        return ServerResponse.createBySuccess(result);

    }
}
